package models

import (
	"roles/models/sys_auth"
	"roles/models/sys_role"

	"roles/utils"
	"time"

	"github.com/beego/beego/v2/client/orm"
	_ "github.com/go-sql-driver/mysql"
)

func init() {
	_ = orm.RegisterDataBase("default", "mysql", utils.MYSQL_URL)
	orm.SetMaxIdleConns("default", 50)
	orm.SetMaxOpenConns("default", 100)

	db, _ := orm.GetDB("default")
	db.SetConnMaxLifetime(10 * time.Minute)

	orm.RegisterModel(
		new(sys_auth.SysAuth),
		new(sys_role.SysRole),
		new(sys_role.SysRoleAuth),
	)
}
